﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cn.Cellula.Biz.Port;
using Cn.Edwon.Spring;
using Cn.Cellula.Model;
using System.Collections.Generic;
using Cn.Edwon.Web.Support;
using Cn.Cellula.Model.System;

namespace Cn.Cellula.Website.Admin.Content.Area {
    public partial class List : PageSupport {
        IAreaBiz biz = BizFactory.Get<IAreaBiz>();
        String CountryKey = null;
        String ProvinceKey = null;
        protected void Page_Load(object sender, EventArgs e) {
            CountryKey = Request.QueryString["cid"];
            ProvinceKey = Request.QueryString["pic"];
            if (!Page.IsPostBack) {
                LoadCountries();
            }
        }
        #region 装载列表
        private void LoadCountries() {
            IList<TSysAreaCountryEO> list = biz.LoadAll<TSysAreaCountryEO>();
            this.gvCountry.DataSource = list;
            this.gvCountry.DataBind();
            if (String.IsNullOrEmpty(CountryKey)) {
                if (list != null && list.Count > 0) {
                    LoadProvinces(list[0].CountryKey);
                }
            } else {
                LoadProvinces(CountryKey);
            }

        }

        private void LoadProvinces(String rCountryKey) {
            IList<TSysAreaProvinceEO> list = biz.LoadProvinceByCountry(rCountryKey);
            this.gvProvince.DataSource = list;
            this.gvProvince.DataBind();
            if (String.IsNullOrEmpty(ProvinceKey)) {
                if (list != null && list.Count > 0) {
                    LoadCities(list[0].ProvinceKey);
                }
            } else {
                LoadCities(ProvinceKey);
            }
        }

        private void LoadCities(String rProvinceKey) {
            IList<TSysAreaCityEO> list = biz.LoadCityByProvince(rProvinceKey);
            this.gvCity.DataSource = list;
            this.gvCity.DataBind();
        }
        #endregion

        #region 国家部分
        protected void btn_country_add_Click(object sender, EventArgs e) {

        }

        protected void btn_country_update_Click(object sender, EventArgs e) {

        }

        protected void btn_type_delete_Click(object sender, EventArgs e) {

        }

        protected void gvCountry_RowCommand(object sender, GridViewCommandEventArgs e) {

        }
        #endregion

        #region 省部分
        protected void btn_ProvinceAdd_Click(object sender, EventArgs e) {

        }

        protected void btn_ProvinceUpdate_Click(object sender, EventArgs e) {

        }

        protected void btn_ProvinceDel_Click(object sender, EventArgs e) {

        }

        protected void gvProvince_RowCommand(object sender, GridViewCommandEventArgs e) {

        }
        #endregion

        #region 市部分
        protected void btn_CityAdd_Click(object sender, EventArgs e) {

        }

        protected void btn_CityUpdate_Click(object sender, EventArgs e) {

        }

        protected void btn_CityDel_Click(object sender, EventArgs e) {

        }

        #endregion

    }
}
